#ifndef __HAPTICS_H__
#define __HAPTICS_H__
#include <hdl/hdl.h>
#include <string>

const bool bBlocking	= true;
const bool bNonBlocking = false;

class CHaptics
{
	// ContactCB = Main loop of 1000Hz, get-state = on-demand
	friend HDLServoOpExitCode ContactCB(void* pParam);
	friend HDLServoOpExitCode GetstateCB(void* pParam);

	public:
		// Constructor & Destructor
		 CHaptics();
		~CHaptics();
	
		// Init will initialize everything for you. Check docs for return values for errors. UnInit is woven into the destructor
		int Init();

		// Basic functions
		void getPosition(double pos[3]);
		bool isButtonDown();
		bool isDeviceCalibrated();
		
		// Synching functions. fromServo will call the GetStateCB, the state will call synch.
		void synchFromServo();
		void synch();

		// Testing functions
		bool testHDLError(std::string str);
		void Test();

	private:
		// Handle to the haptic device
		HDLDeviceHandle devHandle;

		// Servo Operation Exit Code
		HDLServoOpExitCode ServoOp;

		// Servo variables
		double m_posServo[3];
		bool   m_buttonServo;
		double m_forceServo[3];

		// App variables
		double m_posApp[3];
		bool   m_buttonApp;

		// Workspace: Returned dimensions in the array are minx, miny, minz, maxx, maxy, maxz
		//													left, bottom, far, right, top, near)
		double m_workspace[6];
};
#endif